{include file="common_top.html"}
{include file="common_head.html"}
{include file="common_center.html"}
<div class="app-wrapper">
	{include file="common_appheader.html"}
	<div class="app-body">
		<div class="content clearfix">
			<div class="action-member">
				{include file="member_common_navg.html"}
				<div class="detail page-member_mypage page-member_mypassword">
					<form action="/index.php?a=member&m=mypassword&t=ajax" method="post" name="form_password">
						<div class="info">
							<h1>我的密码</h1>
							<h2>为了更好的保护您的帐号安全，建议设置和其它网站不同的密码</h2>
						</div>
						<div class="panel">
							<div class="loading"></div>
							<div class="block-page-common_message success"><div class="message">密码修改成功。</div></div>
							<table>
								<tr class="passwordold">
									<td class="title">当前密码：</td>
									<td class="control"><input type="password" name="passwordold" class="dy-text" /></td>
									<td class="message"><span></span></td>
								</tr>
								<tr class="passwordold"><td></td><td colspan="2" class="notice"></td></tr>
								<tr class="passwordnew">
									<td class="title">新密码：</td>
									<td class="control"><input type="password" name="passwordnew" class="dy-text" /></td>
									<td class="message"><span></span></td>
								</tr>
								<tr class="passwordnew"><td></td><td colspan="2" class="notice">密码由6-30个字符组成，区分大小写</td></tr>
								<tr class="passwordstrong">
									<td class="title">密码强度：</td>
									<td class="control"><div class="passwordstrongbar"></div></td>
									<td class="message"><span></span></td>
								</tr>
								<tr class="passwordstrong"><td></td><td colspan="2" class="notice">为了提升您的密码安全性，建议使用英文字母加数字或符号的混合密码</td></tr>
								<tr class="passwordcfm">
									<td class="title">确认新密码：</td>
									<td class="control"><input type="password" name="passwordcfm" class="dy-text" /></td>
									<td class="message"><span></span></td>
								</tr>
								<tr class="passwordcfm"><td></td><td colspan="2" class="notice"></td></tr>
								<tr class="pagesubmit">
									<td class="title"></td>
									<td class="control" colspan="2">
										<input type="submit" value="确　定" class="dy-button blue" />
										<span class="message"><span></span></span>
									</td>
								</tr>
							</table>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
	{include file="common_appfooter.html"}
</div>
<script type="text/javascript">
{literal}
$(function(){
	var html = "<div style='text-align:center;padding:2px 0px 3px;color:#000000;' class='msg'>&nbsp;</div>";
	html += "<div style='position:absolute;overflow:hidden;top:0px;width:0px;background:#000000;' class='score'>";
	html += "	<div style='text-align:center;padding:1px 0px 3px;color:#FFFFFF;width:" + $(".passwordstrongbar").innerWidth() + "px;' class='msg'>&nbsp;</div>";
	html += "</div>";
	$(".passwordstrongbar").html(html).css({"position":"relative", "width":"100%", "background":"#EEEEEE"});
	$("input[name=passwordnew]").on("input", function(){
		var vals = [
			{color:'#AA0033',txt:'不合格'},
			{color:'#AA0033',txt:'差'},
			{color:'#FFCC33',txt:'中'},
			{color:'#2D98F3',txt:'良'},
			{color:'#76C261',txt:'优'}
		];
		var password = $(this).val();
		var score = $.fn.assessPassword(password);
		var lv = password.length >= 6 ? (Math.ceil(score / 20) - 1) : 0;
		$(".passwordstrongbar .msg").html(vals[lv].txt);
		$(".passwordstrongbar .score").css({"width": score + "%", "background": vals[lv].color});
	});

	$("form[name=form_password]").submit(function(){
		$.fn.dyAjaxForm(this, {dataType: "JSON", onEvent: {beforeSend:function(){
			$(".page-member_mypage .loading").show(300);
		}, success: function(result){
			if(result.state){
				$(".block-page-common_message").show(300);
			}else{
				for(var k in result.message){
					if($("." + k + " .message span").length){
						$("." + k + " .message span").html(result.message[k]).show(300);
						$("body").one('mousedown', function(){
							$("." + k + " .message span").hide(300);
						});
					}else{
						$(".pagesubmit .message span").html(result.message[k]).show(300);
						$("body").one('mousedown', function(){
							$(".pagesubmit .message span").hide(300);
						});
					}
				}
			}
			$(".page-member_mypage .loading").hide(300);
		}, error: function(jqXHR, textStatus, errorThrown){
			$(".page-member_mypage .pagesubmit .message span").show(300).html("AJAX请求错误[" + errorThrown + "]。");
			$("body").one('mousedown', function(){
				$(".page-member_mypage .pagesubmit .message span").hide(300);
			});
			$(".page-member_mypage .loading").hide(300);
		}}});
		return false;
	});
});
{/literal}
</script>
{include file="common_bottom.html"}
